package mysql.cs.packet;

import common.Util.ByteUtil;
import mysql.MysqlPacket;

import java.io.IOException;

/**
 * COM_QUERY response
 *   response to a COM_QUERY packet
 *
 *   payload
 *     lenenc-int     number of columns in the resultset
 */
public class QueryResHeaderPacket extends MysqlPacket {
    public long numberOfCol;
    public  long extra;
    public void encode(byte[] data) throws IOException{
        int index=0;
        byte[] numberOfColbytes=ByteUtil.readBinaryCodedLengthBytes(data,index);
        numberOfCol=ByteUtil.readLengthCodedBinary(numberOfColbytes,index);
        index+=numberOfColbytes.length;
        if(index<data.length-1){
            extra=ByteUtil.readLengthCodedBinary(data,index);
        }
    }
    public byte[] decode()throws IOException{
        //不可能
        return null;
    }

    public long getNumberOfCol() {
        return numberOfCol;
    }

    public void setNumberOfCol(long numberOfCol) {
        this.numberOfCol = numberOfCol;
    }

    public long getExtra() {
        return extra;
    }

    public void setExtra(long extra) {
        this.extra = extra;
    }
}
